/*
 * @Author: liguoyan
 * @Date: 2021-11-11 12:35:19
 * 功能权限组件
 */
import { defineComponent } from 'vue';
import { usePermissionStore } from '@/store/permission';

const ModelButtonRole = defineComponent({
  name: 'ModelButtonRole',
  props: {
    funckey: {
      type: String,
      required: true,
      default: ''
    }
  },
  setup: (props, { slots, attrs, emit }) => {
    const permissionStore: any = usePermissionStore();
    const keys: string[] = permissionStore.buttonRulesList.map((item: any) => {
      return item.resourceCode;
    });
    const show = keys.indexOf(props?.funckey) > -1 ? true : false;
    return () => {
      const { funckey } = props;
      return <>{show ? slots.default?.() : null}</>;
    };
  }
});

export default ModelButtonRole;
